<template>
    <div class="downloadIndex" style="width: 100%">

        <el-button class="el-button--primary">实验一  下载功能完善</el-button>
        <br/>
        <el-button class="el-button--warning" v-for="(e,i) in files" :key="i" @click="download(e)">{{e}}</el-button>
    </div>
</template>

<script>
    // import New from './components/New.vue';
    import  Axios from 'axios';
    export default {

        name: "Download",
        components: {
            // New,Old,
        },
        props: {
            sampleP: {
                type: Number,
                default: 0
            },
        },
        data() {
            return {
                sampleD: 'value',
                files: [],
            }
        },
        computed: {
            // sampleC() {
            //     return this.sampleD+'--';
            // }
        },
        created() {
        },
        mounted() {
           /* this.$http({
                method: 'get',
                url: '/listFiles',
            }).then(res => {
                console.log(res.data);
                // this.files = res.data.files;

                this.files = res.data.files;
                this.$message.warning(JSON.stringify(res.data))
                //this.total = res.data.total;
                //this.newsResults = res.data.results;
            }).catch(res => {
                this.$message.warning(JSON.stringify(res.data))
            });*/
        },
        methods: {
            sampleM() {

            },
            download(e) {
                this.$message.warning("开始下载" + e);
                // window.location.href='http://localhost:9090/download/'+e;
                window.location.href=Axios.defaults.baseURL+'/download/'+e;
                //注意这里不能发请求
                // this.$http({
                //     method: 'get',
                //     url: '/download/' + e,
                //
                // }).then(
                //     () => {
                //         console.log("got")
                //         //this.total = res.data.total;
                //         //this.newsResults = res.data.results;
                //     }).catch(res => {
                //     this.$message.warning(JSON.stringify(res.data))
                // });
            }
        },
        watch: {
            // sampleC(newValue, oldValue) {
            //
            // }
        },
    }
</script>

<style scoped>
    /*<style lang='scss' scoped>*/
    .downloadIndex {
        background-color: rgba(255, 68, 155, 0.72);
    }
</style>